#!/bin/bash

#卸载旧版本docker
sudo apt-get remove docker docker-engine docker.io containerd runc -y
#更新及安装依赖包
sudo apt-get update -y
sudo apt-get install  apt-transport-https   ca-certificates    curl  gnupg-agent software-properties-common -y
#添加docker官方GPG秘钥，将阿里源设置为docker下载源
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
#设置docker存储库
sudo add-apt-repository \
   "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu \
   $(lsb_release -cs) \
   stable" -y
#更新apt程序包索引，并安装最新版本的Docker Engine和容器
sudo apt-get install docker-ce docker-ce-cli containerd.io -y

#配置加速器
cat > /etc/docker/daemon.json << EOF
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "registry-mirrors": ["https://m5u60dx2.mirror.aliyuncs.com"]
}
EOF
#重新加载文件及重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker

